#ifndef ANALOG_TRACKER_H
#define ANALOG_TRACKER_H


#define S0(X)  ( (X) ? DL_GPIO_setPins(GPIO_TRACKER_PORT,GPIO_TRACKER_PIN_S0_PIN) : DL_GPIO_clearPins(GPIO_TRACKER_PORT,GPIO_TRACKER_PIN_S0_PIN) )
#define S1(X)  ( (X) ? DL_GPIO_setPins(GPIO_TRACKER_PORT,GPIO_TRACKER_PIN_S1_PIN) : DL_GPIO_clearPins(GPIO_TRACKER_PORT,GPIO_TRACKER_PIN_S1_PIN) )
#define S2(X)  ( (X) ? DL_GPIO_setPins(GPIO_TRACKER_PORT,GPIO_TRACKER_PIN_S2_PIN) : DL_GPIO_clearPins(GPIO_TRACKER_PORT,GPIO_TRACKER_PIN_S2_PIN) )

typedef struct {
    uint8_t analog_sensors[8];
    uint8_t digital_sensors[8]; // 传感器值
    uint8_t threshold;        // 阈值
    uint8_t last_threshold;    // 上次阈值
    uint8_t delta_threshold;    // 阈值变化量
    uint8_t delta_threshold_dead_zone;   // 阈值变化量死区

} TrackerData;

extern TrackerData tracker_data;

void analog_tracker_init(void);
void get_analog_tracker_values(TrackerData* trackerData);
void get_digital_tracker_values(TrackerData* trackerData);
void update_tracker_values(void);

void ADC12_TRACKER_INST_IRQHandler(void);

#endif // ANALOG_TRACKER_H